package com.zgm.ch03._4_11;

import org.springframework.beans.factory.BeanFactory;
import org.springframework.beans.factory.xml.XmlBeanFactory;
import org.springframework.core.io.ClassPathResource;

/**
 * bean的继承
 * @author Administrator
 *
 */
public class SimpleBean {

	private String name;
	private int age;
	
	public static void main(String[] args){
//		BeanFactory beanFactory = new XmlBeanFactory(new ClassPathResource("/META-INF/spring/ch03/_4_11/_4_11-context.xml"));
		//可以
		BeanFactory beanFactory = new XmlBeanFactory(new ClassPathResource("com/zgm/ch03/_4_11/_4_11-context.xml"));
		//不行 
//		BeanFactory beanFactory = new XmlBeanFactory(new ClassPathResource("classpath:com/zgm/ch03/_4_11/_4_11-context.xml"));
		
		SimpleBean child1 = (SimpleBean) beanFactory.getBean("child1");
		SimpleBean child2 = (SimpleBean) beanFactory.getBean("child2");
		System.out.println(child1);
		System.out.println(child2);
	}
	
	@Override
	public String toString(){
		final StringBuilder sb = new StringBuilder();
		sb.append("SimpleBean");
		sb.append("{name=").append(name);
		sb.append(", age=").append(age);
		sb.append("}");
		
		return sb.toString();
		
	}

	public void setName(String name) {
		this.name = name;
	}

	public void setAge(int age) {
		this.age = age;
	}
	
	
	
	
}
